import * as API from "../../utils/awardUrl"
import * as actionType from "../types/award"
import {RES_OK_CODE} from "../types/index" 

import {post} from "../../utils/url"

export function LoadAwardCenter(params) {
  return (dispatch, getState) => {
    post(API.loadAwardCenterAPI())
    .then(res => res.json())
    .then(data => {
      try {
        dispatch({
          type: actionType.REQUEST_AWARD_CENTER,
          data: data
        });
      } catch (e) {
        //console.error(e.toString());
      }
    });
  };
}

export function  loadawardDetail(gameCode,pageNo,cb=()=>{}) {
  return (dispatch,getState) =>{
    post(API.loadawardDetailAPI(),{
      gameCode,
      pageNo
    })
    .then(res => res.json())
    .then(data => {
        dispatch({
          type: actionType.REQUEST_AWARD_DETAIL,
          data: {
            type:gameCode,
            pageNo,
            data
          }
        })
        cb()
    });
  }
}